package cn.cycleif.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @Date: 25/2/17-14:05
 * @Desc:
 */
@Getter
public enum ActionTypeEnum implements IEnum<Integer> {

  VOTE_UP(0, "点赞", "VOTE_UP"),
  VOTE_DOWN(1, "点踩", "VOTE_DOWN"),
  COMMENT(2, "评论", "COMMENT"),
  ANSWER(3, "回答", "ANSWER"),
  DELETED(4, "删除", "DELETED"),
  CLOSED(5, "关闭", "CLOSED"),
  WARN(6, "警告", "WARN"),
  BANNED(7, "封禁", "BANNED"),
  ADOPTED(10, "采纳", "ADOPTED"),
  REJECTED(8, "拒绝", "REJECTED"),
  ACCEPTED(9, "接受", "ACCEPTED"),
  ;

  @JsonValue
  private final int    code;
  private final String desc;
  private final String sign;

  ActionTypeEnum(int code, String desc, String sign) {
    this.code = code;
    this.desc = desc;
    this.sign = sign;
  }

  public static ActionTypeEnum fromCode(Integer code) {
    for (ActionTypeEnum statusEnum : ActionTypeEnum.values()) {
      if (statusEnum.getValue()
                    .equals(code)) {
        return statusEnum;
      }
    }
    return null;
  }

  @Override
  public Integer getValue() {
    return this.code;
  }
}